//页面loading
let stateCheck = setInterval(() => {
    if (document.readyState === 'complete') {

        setTimeout(function () {
            $('.Loading-Box').css({"transform":"translateY(-100%)"});
            $('body,html').removeClass('loading');
        },500);
        clearInterval(stateCheck);
        // document ready

    }
}, 100);
//导航条特性
$(function () {
    const $nav = $('nav');
    const $logo = $('.nav-logo');
    const $navbarToggle = $('.navbar-toggle');
    const Limit = 500;//收起高度
    const Timeout = 1000;//收起延迟
    let hidden;
    //首次加载判断位置
    AutoHiddenNavBar();
    $(window).on('scroll',AutoHiddenNavBar);
    //鼠标移入显示导航条
    $nav.hover(function(){
        if ($nav.offset().top>Limit){
            $nav.css({"transform" :"translateY(0)"});
            $logo.css({"width":"248.2px"});
        }
    },function() {
        if ($nav.offset().top>Limit){
            if ($navbarToggle.attr('aria-expanded')==="true"){
                return;
            }
            $('nav').css({"transform" :"translateY(-50px)"});
            $logo.css({"width":"42px"});
        }
    });
    function AutoHiddenNavBar() {
        if ($nav.offset().top>Limit){
            //设定特定条件样式======================\
            $nav.addClass("Scroll-navbar");
            $logo.css({"width":"42px"});

            //自动隐藏导航条========================\
                //重置隐藏计时
            $nav.css({"transform" :"translateY(0)"});
            clearTimeout(hidden);
                //判断导航条隐藏启用条件
            if ($navbarToggle.attr('aria-expanded')==="true"){
                return;
            }
                //启用隐藏计时
            hidden = setTimeout(function () {
                if ($navbarToggle.attr('aria-expanded')==="true"){
                    return;
                }
                $('nav').css({"transform" :"translateY(-50px)"});
            },Timeout);
        }else{
            $nav.css({"transform" :"translateY(0)"});
            clearTimeout(hidden);
            $nav.removeClass("Scroll-navbar");
            $logo.css({"width":"248.2px"});
        }
    }
});

//获取用户登入讯息
sessionStorage.setItem('test','测试');

console.log(sessionStorage.getItem('test'));

/*$(window).on("mousewheel",function (e) {
       if ($nav.offset().top>Limit){
           //设定特定条件样式
           console.log($nav.offset().top);
           $nav.addClass("Scroll-navbar");
           $logo.css({"width":"42px"});
            //获取滚轮状态
           var delta = (e.originalEvent.wheelDelta && (e.originalEvent.wheelDelta > 0 ? 1 : -1))|| (e.originalEvent.detail && (e.originalEvent.detail > 0 ? -1 : 1));
           if(delta===-1){
               //滚轮下，1.5秒后隐藏导航条
               $('nav').css({"transform" :"translateY(0)"})
               clearTimeout(hidden);
               hidden = setTimeout(function () {
                    $('nav').css({"transform" :"translateY(-50px)"})
               },1500)
           }else{
               //滚轮上，恢复显示导航条
               clearTimeout(hidden);
               $('nav').css({"transform" :"translateY(0)"})
           }
           console.log(delta);
       }else{
           $nav.removeClass("Scroll-navbar");
           $logo.css({"width":"248.2px"})
       }
});*/
